fix_documentation_build
authorAron Xu <aron@debian.org>
Wed, 22 Mar 2017 08:31:14 +0000 (08:31 +0000)
committerJean Baptiste Favre <debian@jbfavre.org>
Wed, 22 Mar 2017 08:31:14 +0000 (08:31 +0000)
Gbp-Pq: Name 0005-fix_documentation_build.patch

doc/admin-guide/configuration/cache-basics.en.rst
doc/admin-guide/files/records.config.en.rst
doc/conf.py
doc/developer-guide/api/functions/TSHttpTxnClientPacketMarkSet.en.rst
doc/developer-guide/api/functions/TSHttpTxnClientPacketTosSet.en.rst
doc/developer-guide/api/functions/TSHttpTxnServerPacketMarkSet.en.rst
doc/developer-guide/api/functions/TSHttpTxnServerPacketTosSet.en.rst
doc/developer-guide/api/functions/TSLifecycleHookAdd.en.rst
doc/developer-guide/architecture/architecture.en.rst
doc/developer-guide/architecture/consistency.en.rst
doc/ext/traffic-server.py

index 7351d1e0a884a586c1f82391189df4c4977cefb2..8770e8ab45ff490c68b41a32a32d6c3eaa9bfb48 100644 (file)
@@ -683,7 +683,7 @@ cases the content will be buffered in ram while waiting to be sent to the
 client. This could potentially also happen for ``POST`` requests if the client
 connection is fast and the origin server connection slow. If very large objects
 are being used this can cause the memory usage of Traffic Server to become
-`very large <https://issues.apache.org/jira/browse/TS-1496>`_.
+very large (See issue :ts:jira:`1496`).
 
 This problem can be ameliorated by controlling the amount of buffer space used
 by a transaction. A high water and low water mark are set in terms of bytes
index 4ac9e40fb98bdf7742cfdd4728e204e59901246d..cba0f200570cd29101923dae464119e18ec1b5c6 100644 (file)
@@ -1073,7 +1073,7 @@ ip-resolve
          performed. The result is cached (if allowed otherwise). This option is
          vulnerable to cache poisoning if an incorrect ``Host`` header is
          specified, so this option should be used with extreme caution.  See
-         bug TS-2954 for details.
+         bug :ts:jira:`2954` for details.
    ===== ======================================================================
 
    If all of these conditions are met, then the origin server IP address is
index c34ad4fb140f69d28852793ae506d12d89c5256e..25cb5558adeaea0a772afd146342a04d9204d719 100644 (file)
@@ -161,44 +161,9 @@ pygments_style = 'sphinx'
 nitpicky=1
 
 # Autolink issue references
-
-from docutils import nodes
-from docutils.parsers.rst import states
-from docutils.utils import unescape
-
-# Customize parser.inliner in the only way that Sphinx supports.
-# docutils.parsers.rst.Parser takes an instance of states.Inliner or a
-# subclass but Sphinx initializes it from
-# SphinxStandaloneReader.set_parser('restructuredtext') which is called
-# from Publisher.set_components() and initializes the parser without
-# arguments.
-
-BaseInliner = states.Inliner
-class Inliner(BaseInliner):
-  def __init__(self):
-    BaseInliner.__init__(self)
-
-    issue_pattern = re.compile(u'''
-      {start_string_prefix}
-      TS-\d+
-      {end_string_suffix}'''.format(
-        start_string_prefix=self.start_string_prefix,
-        end_string_suffix=self.end_string_suffix),
-      re.VERBOSE | re.UNICODE)
-
-    self.implicit_dispatch.append((issue_pattern, self.issue_reference))
-
-  def issue_reference(self, match, lineno):
-    text = match.group(0)
-
-    rawsource = unescape(text, True)
-    text = unescape(text, False)
-
-    refuri = 'https://issues.apache.org/jira/browse/' + text
-
-    return [nodes.reference(rawsource, text, refuri=refuri)]
-
-states.Inliner = Inliner
+# moved into traffic_server Sphinx extension
+trafficserver_jira_url='https://issues.apache.org/jira/browse/'
+trafficserver_github_url='https://github.com/apache/trafficserver/issues/'
 
 # -- Options for HTML output ---------------------------------------------------
 
@@ -347,6 +312,8 @@ latex_documents = [
 # documents and includes the same brief description in both the HTML
 # and manual page outputs.
 
+from docutils import nodes
+from docutils.utils import unescape
 from docutils.transforms import frontmatter
 from sphinx.writers import manpage
 
index 437f528b03643b5da43a6cbcdb0792eb75230553..0272a271c550bc302654b098ad5d4858da9c8389 100644 (file)
@@ -41,4 +41,4 @@ See Also
 
 .. _Traffic Shaping:
                  https://cwiki.apache.org/confluence/display/TS/Traffic+Shaping
-   :ts:cv:`proxy.config.net.sock_packet_mark_in` and TS-1090
+   :ts:cv:`proxy.config.net.sock_packet_mark_in` and :ts:jira:`1090`
index f1b694b9167f44d881cf56d894f9276b737c2c27..d5f1f3aa8b1ccac76c1077351d1bf20ca5a5a432 100644 (file)
@@ -47,4 +47,4 @@ See Also
 
 .. _Traffic Shaping:
                  https://cwiki.apache.org/confluence/display/TS/Traffic+Shaping
-   :ts:cv:`proxy.config.net.sock_packet_tos_in` and TS-1090
+   :ts:cv:`proxy.config.net.sock_packet_tos_in` and :ts:jira:`1090`
index af31dd84ed3eaacd043394e07d9394ef3a204d0b..28c4c0dfe2ddab151b6b16614e35902de9045b6c 100644 (file)
@@ -45,4 +45,4 @@ See Also
 
 .. _Traffic Shaping:
                  https://cwiki.apache.org/confluence/display/TS/Traffic+Shaping
-   :ts:cv:`proxy.config.net.sock_packet_mark_out` and TS-1090
+   :ts:cv:`proxy.config.net.sock_packet_mark_out` and :ts:jira:`1090`
index c412be1d08f4926de88d508bd86e761386b8a3ca..60a7f3da7d9f4d52fbe607ce1e06f0da3c6452d1 100644 (file)
@@ -49,4 +49,4 @@ See Also
 
 .. _Traffic Shaping:
                  https://cwiki.apache.org/confluence/display/TS/Traffic+Shaping
-   :ts:cv:`proxy.config.net.sock_packet_tos_out` and TS-1090
+   :ts:cv:`proxy.config.net.sock_packet_tos_out` and :ts:jira:`1090`
index 5499bc02ed9f728d3fe68072acbe95c7cc4ba9d3..db71c92641634e3701fca2336c4a0777ad3ee527 100644 (file)
@@ -130,7 +130,7 @@ History
 =======
 
 Lifecycle hooks were introduced to solve process initialization ordering issues
-(TS-1487). Different API calls required different modules of |TS| to be
+:ts:jira:`1487`. Different API calls required different modules of |TS| to be
 initialized for the call to work, but others did not work that late in
 initialization, which was problematic because all of them could effectively
 only be called from :func:`TSPluginInit` . The solution was to move
index a38a1a56e0278cb80b0f684efb87bd07d7f1a9d0..07551f81b62ff2d5739429bc3bfb365e34979510 100644 (file)
@@ -1147,12 +1147,12 @@ including the size of each stripe.
 
 .. [#store-disk-array]
 
-   `Work is under way <https://issues.apache.org/jira/browse/TS-2020>`_ on
-   extending this to include objects that are in the memory cache.
+   Work is under way on extending this to include objects that are in the
+   memory cache (See issue :ts:jira:`2020`).
 
 .. [#coalesced-spans]
 
    This linked list is mostly ignored in later processing, causing all but one
    file or directory storage units on the same device to be ignored. See
-   `TS-1869 <https://issues.apache.org/jira/browse/TS-1869>`_.
+   :ts:jira:`1869`.
 
index c5d5fafd20eba4b00a45b75281d3d6c057d904f5..413cff54d2e6c20fa7a8ffca67fa926c90b5e286 100644 (file)
@@ -59,7 +59,7 @@ Volume Tagging
 ~~~~~~~~~~~~~~
 
 Currently, :term:`cache volumes <cache volume>` are allocated somewhat
-arbitrarily from storage elements. `This enhancement <https://issues.apache.org/jira/browse/TS-1728>`__
+arbitrarily from storage elements. `This enhancement :ts:jira:`1728``__
 allows :file:`storage.config` to assign :term:`storage units <storage unit>` to
 specific :term:`volumes <cache volume>` although the volumes must still be
 listed in :file:`volume.config` in general and in particular to map domains to
index 50d45deb89578fe325acc61eb61f6d62c4ea8667..d8de39144cfd15be177bc9def832be47249e26d2 100644 (file)
@@ -26,7 +26,8 @@
     :license: Apache
 """
 
-from docutils import nodes
+from docutils import nodes, utils
+from docutils.parsers.rst.roles import set_classes
 from docutils.parsers import rst
 from docutils.parsers.rst import directives
 from sphinx.domains import Domain, ObjType, std
@@ -34,6 +35,102 @@ from sphinx.roles import XRefRole
 from sphinx.locale import l_, _
 import sphinx
 
+# Autolink for Trafficserver issues
+# Moved from doc/conf.py, now integrated into TS domain
+#
+# Two types of issues supported:
+# * Jira: for archive purpose only (after the Jira to Github move)
+# * Github: for new issues (after the Jira to Github move)
+#
+# Syntax:
+# :ts:jira:`XXXX` where XXXX is the issue number
+# :ts:github:`XXXX` where XXXX is the issue number
+#
+# Output
+# * Prefix issue number with 'TS-'
+# * Render HTML link:
+#   - either to https://issues.apache.org/jira/browse/TS-XXXX
+#   - or to https://github.com/apache/trafficserver/issues/XXXX
+
+def ts_jira_role(name, rawtext,  issue_num, lineno, inliner, options={}, content=[]):
+  """Link to a Trafficserver Jira issue.
+
+  Returns 2 part tuple containing list of nodes to insert into the
+  document and a list of system messages.  Both are allowed to be
+  empty.
+
+  :param name: The role name used in the document.
+  :param rawtext: The entire markup snippet, with role.
+  :param issue_num: The issue number marked with the role.
+  :param lineno: The line number where rawtext appears in the input.
+  :param inliner: The inliner instance that called us.
+  :param options: Directive options for customization.
+  :param content: The directive content for customization.
+  """
+  app = inliner.document.settings.env.app
+  try:
+    base_url = app.config.trafficserver_jira_url
+    if not base_url:
+      raise AttributeError
+  except AttributeError, err:
+    raise ValueError('trafficserver_jira_url configuration values not set (%s)' % str(err))
+  #
+  issue_prefix = 'TS-'
+  node = make_link_node(rawtext, app, base_url, issue_prefix, issue_num, options)
+  return [node], []
+
+def ts_github_role(name, rawtext,  issue_num, lineno, inliner, options={}, content=[]):
+  """Link to a Trafficserver Github issue.
+
+  Returns 2 part tuple containing list of nodes to insert into the
+  document and a list of system messages.  Both are allowed to be
+  empty.
+
+  :param name: The role name used in the document.
+  :param rawtext: The entire markup snippet, with role.
+  :param text: The text marked with the role.
+  :param lineno: The line number where rawtext appears in the input.
+  :param inliner: The inliner instance that called us.
+  :param options: Directive options for customization.
+  :param content: The directive content for customization.
+  """
+  app = inliner.document.settings.env.app
+  try:
+    base_url = app.config.trafficserver_github_url
+    if not base_url:
+      raise AttributeError
+  except AttributeError, err:
+    raise ValueError('trafficserver_github_url configuration values not set (%s)' % str(err))
+  #
+  issue_prefix = ''
+  node = make_link_node(rawtext, app, base_url, issue_prefix, issue_num, options)
+  return [node], []
+
+def make_link_node(rawtext, app, base_url, issue_prefix, issue_num, options):
+  """Create a link to a Apache Jira resource.
+
+  :param rawtext: Text being replaced with link node.
+  :param app: Sphinx application context
+  :param type: Link type ('jira' or 'github')
+  :param slug: ID of the thing to link to
+  :param options: Options dictionary passed to role func.
+  """
+  #
+  try:
+      issue_num_int = int(issue_num)
+      if issue_num_int <= 0:
+          raise ValueError
+  except ValueError:
+    raise ValueError('Trafficserver issue number must be a number greater than or equal to 1; '
+                     '"%s" is invalid.' % text, line=lineno)
+  #
+  base_url = base_url + issue_prefix + '{0}'
+  ref = base_url.format(issue_num)
+  set_classes(options)
+  node = nodes.reference(rawtext, issue_prefix + issue_num, refuri=ref,
+                         **options)
+  return node
+
 class TSConfVar(std.Target):
     """
     Description of a traffic server configuration variable.
@@ -262,6 +359,10 @@ class TSStatRef(XRefRole):
     def process_link(self, env, ref_node, explicit_title_p, title, target):
         return title, target
 
+class TSIssueRef(XRefRole):
+    def process_link(self, env, ref_node, explicit_title_p, title, target):
+        return 'TS-' + title, 'https://issues.apache.org/jira/browse/TS-' + target
+
 class TrafficServerDomain(Domain):
     """
     Apache Traffic Server Documentation.
@@ -273,7 +374,8 @@ class TrafficServerDomain(Domain):
 
     object_types = {
         'cv': ObjType(l_('configuration variable'), 'cv'),
-        'stat': ObjType(l_('statistic'), 'stat')
+        'stat': ObjType(l_('statistic'), 'stat'),
+        'jira': ObjType(l_('jira'), 'jira')
     }
 
     directives = {
@@ -283,17 +385,21 @@ class TrafficServerDomain(Domain):
 
     roles = {
         'cv' : TSConfVarRef(),
-        'stat' : TSStatRef()
+        'stat' : TSStatRef(),
+        'jira' : ts_jira_role,
+        'github' : ts_github_role
     }
 
     initial_data = {
         'cv' : {}, # full name -> docname
-        'stat' : {}
+        'stat' : {},
+        'issue' : {}
     }
 
     dangling_warnings = {
         'cv' : "No definition found for configuration variable '%(target)s'",
-        'stat' : "No definition found for statistic '%(target)s'"
+        'stat' : "No definition found for statistic '%(target)s'",
+        'issue' : "No definition found for issue '%(target)s'"
     }
 
     def clear_doc(self, docname):
@@ -305,6 +411,10 @@ class TrafficServerDomain(Domain):
         for var, doc in stat_list.items():
             if doc == docname:
                 del stat_list[var]
+        issue_list = self.data['issue']
+        for var, doc in issue_list.items():
+            if doc == docname:
+                del issue_list[var]
 
     def find_doc(self, key, obj_type):
         zret = None
@@ -313,6 +423,8 @@ class TrafficServerDomain(Domain):
             obj_list = self.data['cv']
         elif obj_type == 'stat' :
             obj_list = self.data['stat']
+        elif obj_type == 'issue' :
+            obj_list = self.data['issue']
         else:
             obj_list = None
 
@@ -322,15 +434,20 @@ class TrafficServerDomain(Domain):
         return zret
 
     def resolve_xref(self, env, src_doc, builder, obj_type, target, node, cont_node):
-        dst_doc = self.find_doc(target, obj_type)
-        if (dst_doc):
-            return sphinx.util.nodes.make_refnode(builder, src_doc, dst_doc, nodes.make_id(target), cont_node, 'records.config')
+        if obj_type == 'issue':
+            return sphinx.util.nodes.make_refnode(builder, src_doc, src_doc, nodes.make_id(target), cont_node, None)
+        else:
+            dst_doc = self.find_doc(target, obj_type)
+            if (dst_doc):
+                return sphinx.util.nodes.make_refnode(builder, src_doc, dst_doc, nodes.make_id(target), cont_node, 'records.config')
 
     def get_objects(self):
         for var, doc in self.data['cv'].iteritems():
             yield var, var, 'cv', doc, var, 1
         for var, doc in self.data['stat'].iteritems():
             yield var, var, 'stat', doc, var, 1
+        for var, doc in self.data['issue'].iteritems():
+            yield var, var, 'issue', doc, var, 1
 
 # These types are ignored as missing references for the C++ domain.
 # We really need to do better with this. Editing this file for each of
@@ -369,6 +486,8 @@ def setup(app):
     rst.roles.register_generic_role('const', nodes.literal)
 
     app.add_domain(TrafficServerDomain)
+    app.add_config_value('trafficserver_jira_url', None, 'env')
+    app.add_config_value('trafficserver_github_url', None, 'env')
 
     # Types that we want the C domain to consider built in
     for word in EXTERNAL_TYPES: